package com.huikeportal.controller.common;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.Properties;

import com.huikeportal.model.Language;


public class Lang {
	
	private static Properties p = null;
	/**
	 * 获取资源休息
	 * @param lang
	 * @return
	 * @throws UnsupportedEncodingException 
	 * @throws UnsupportedEncodingException 
	 */
	public static Language getInfo(String lang){
		Language language=new Language();
		String rtnStr = null;
		if (p == null || p.size() == 0) {
			try {
				getInfoMap(lang);
			} catch (Exception e) {
				return language;
			}
		}
		if (p.get("login") != null) {
			//设置资源信息
			language.setLogin(p.getProperty("login"));
			language.setSubmit(p.getProperty("submit"));
			language.setSave(p.getProperty("save"));
			language.setCancel(p.getProperty("cancel"));
			language.setSaveok(p.getProperty("saveok"));
			language.setSavefailed(p.getProperty("savefailed"));
			language.setLogout(p.getProperty("logout"));
			language.setLoggedIn(p.getProperty("loggedIn"));
			language.setRememberUser(p.getProperty("rememberUser"));
			language.setChangeyzm(p.getProperty("changeyzm"));
			language.setZhanghaodenglu(p.getProperty("zhanghaodenglu"));
			language.setFooterwz(p.getProperty("footerwz"));
			language.setFooterwz2(p.getProperty("footerwz2"));
			language.setChanpinfuwu(p.getProperty("chanpinfuwu"));
			language.setShujubaogao(p.getProperty("shujubaogao"));
			language.setXinwenzixun(p.getProperty("xinwenzixun"));
			language.setGuanyuwomen(p.getProperty("guanyuwomen"));
			language.setLianxiwomen(p.getProperty("lianxiwomen"));
			language.setTitle(p.getProperty("title"));
			language.setTips(p.getProperty("tips"));
			language.setInputUserName(p.getProperty("inputUserName"));
			language.setOldPassword(p.getProperty("oldPassword"));
			language.setNewPassword(p.getProperty("newPassword"));
			language.setNewPasswordAgain(p.getProperty("newPasswordAgain"));
			language.setModify(p.getProperty("modify"));
			language.setOldPwdErr(p.getProperty("oldPwdErr"));
			language.setNewPwdEmpty(p.getProperty("newPwdEmpty"));
			language.setNewPwdAgEmpty(p.getProperty("newPwdAgEmpty"));
			language.setPwdTwiceWrong(p.getProperty("pwdTwiceWrong"));
			language.setPwdShort(p.getProperty("pwdShort"));
			language.setPwdHasSpace(p.getProperty("pwdHasSpace"));
			language.setSiteSelect(p.getProperty("siteSelect"));
			language.setHistoryIndexComparasion(p.getProperty("historyIndexComparasion"));
			language.setDayLook(p.getProperty("dayLook"));
			language.setWeekLook(p.getProperty("weekLook"));
			language.setMonthLook(p.getProperty("monthLook"));
			language.setYearLook(p.getProperty("yearLook"));
			language.setDetails(p.getProperty("details"));
			language.setFirstPage(p.getProperty("firstPage"));
			language.setLastPage(p.getProperty("lastPage"));
			language.setSkipTo(p.getProperty("skipTo"));
			language.setBasicInfoChange(p.getProperty("basicInfoChange"));
			language.setUserRole(p.getProperty("userRole"));
			language.setUserName(p.getProperty("userName"));
			language.setName(p.getProperty("name"));
			language.setEmail(p.getProperty("email"));
			language.setPhone(p.getProperty("phone"));
			language.setCellPhone(p.getProperty("cellPhone"));
			language.setInputName(p.getProperty("inputName"));
			language.setEmailErr(p.getProperty("emailErr"));
			language.setReport(p.getProperty("report"));
			language.setSequence(p.getProperty("sequence"));
			language.setReportName(p.getProperty("reportName"));
			language.setPubDate(p.getProperty("pubDate"));
			language.setDownload(p.getProperty("download"));
			language.setNoDownloadFile(p.getProperty("noDownloadFile"));
			language.setErrorPage(p.getProperty("errorPage"));
			language.setErrorPage2(p.getProperty("errorPage2"));
			language.setChange(p.getProperty("change"));
			language.setTodayIndex(p.getProperty("todayIndex"));
			language.setWeather(p.getProperty("weather"));
			language.setCompareYesterday(p.getProperty("compareYesterday"));
			language.setCompareLastWeekToday(p.getProperty("compareLastWeekToday"));
			language.setLastWeekToday(p.getProperty("lastWeekToday"));
			language.setToday(p.getProperty("today"));
			language.setYeaterday(p.getProperty("yeaterday"));
			language.setHistoryIndex(p.getProperty("historyIndex"));
			language.setTraffic(p.getProperty("traffic"));
			language.setPos(p.getProperty("pos"));
			language.setZhi(p.getProperty("zhi"));
			language.setRenci(p.getProperty("renci"));
			language.setYuan(p.getProperty("yuan"));
			language.setSiteIndexRanking(p.getProperty("siteIndexRanking"));
			language.setSingleUv(p.getProperty("singleUv"));
			language.setSinglePv(p.getProperty("singlePv"));
			language.setGtklzb(p.getProperty("gtklzb"));
			language.setYgpl(p.getProperty("ygpl"));
			language.setGtxgkzb(p.getProperty("gtxgkzb"));
			language.setGtlgkzb(p.getProperty("gtlgkzb"));
			language.setCaiyangbi(p.getProperty("caiyangbi"));
			language.setJindianlv(p.getProperty("jindianlv"));
			language.setFandianlv(p.getProperty("fandianlv"));
			language.setDangtian(p.getProperty("dangtian"));
			language.setZuijin(p.getProperty("zuijin"));
			language.setTian(p.getProperty("tian"));
			language.setWeek(p.getProperty("week"));
			language.setMonth(p.getProperty("month"));
			language.setYear(p.getProperty("year"));
			language.setCancelDuibi(p.getProperty("cancelDuibi"));
			language.setSquareMeter(p.getProperty("squareMeter"));
			language.setTdl(p.getProperty("tdl"));
			language.setKdj(p.getProperty("kdj"));
			language.setRenxiao(p.getProperty("renxiao"));
			language.setPingxiao(p.getProperty("pingxiao"));
			language.setJkl(p.getProperty("jkl"));
			language.setPjzlsj(p.getProperty("pjzlsj"));
			language.setMinute(p.getProperty("minute"));
			language.setStaff(p.getProperty("staff"));
			language.setRen(p.getProperty("ren"));
			language.setHeadtitle(p.getProperty("headtitle"));
			language.setTraffichelp(p.getProperty("traffichelp"));
			language.setPoshelp(p.getProperty("poshelp"));
			language.setTdlhelp(p.getProperty("tdlhelp"));
			language.setKdjhelp(p.getProperty("kdjhelp"));
			language.setRexiaohelp(p.getProperty("rexiaohelp"));
			language.setPingxiaohelp(p.getProperty("pingxiaohelp"));
			language.setJklhelp(p.getProperty("jklhelp"));
			language.setPjzlsjhelp(p.getProperty("pjzlsjhelp"));
			language.setSiteId(p.getProperty("siteId"));
			language.setPosTime(p.getProperty("posTime"));
			language.setPosNum(p.getProperty("posNum"));
			language.setPose(p.getProperty("pose"));
			language.setMemo(p.getProperty("memo"));
			language.setFromDate(p.getProperty("fromDate"));
			language.setToDate(p.getProperty("toDate"));
			language.setQuery(p.getProperty("query"));
			language.setSubmitType(p.getProperty("submitType"));
			language.setOperation(p.getProperty("operation"));
			language.setDelete(p.getProperty("delete"));
			language.setSiteIdErr(p.getProperty("siteIdErr"));
			language.setPosnumErr(p.getProperty("posnumErr"));
			language.setPoseErr(p.getProperty("poseErr"));
			language.setPleaseChoose(p.getProperty("pleaseChoose"));
			language.setSiteName(p.getProperty("siteName"));
			language.setAdd(p.getProperty("add"));
			language.setImports(p.getProperty("imports"));
			language.setHistoryData(p.getProperty("historyData"));
			language.setRolelist(p.getProperty("rolelist"));
			language.setRoleauth(p.getProperty("roleauth"));
			language.setAllcheck(p.getProperty("allcheck"));
			language.setConfirmDelete(p.getProperty("confirmDelete"));
			language.setWarning(p.getProperty("warning"));
			language.setHaveNotChoose(p.getProperty("haveNotChoose"));
			language.setConfirmSave(p.getProperty("confirmSave"));
			language.setRolenameEmpty(p.getProperty("rolenameEmpty"));
			language.setDeleteRole(p.getProperty("deleteRole"));
			language.setParentRole(p.getProperty("parentRole"));
			language.setRoleName(p.getProperty("roleName"));
			language.setRoleDesc(p.getProperty("roleDesc"));
			language.setBack(p.getProperty("back"));
			language.setRange(p.getProperty("range"));
			language.setBrand(p.getProperty("brand"));
			language.setUnlimited(p.getProperty("unlimited"));
			language.setOthers(p.getProperty("others"));
			language.setChosen(p.getProperty("chosen"));
			language.setChooseLeastOneSite(p.getProperty("chooseLeastOneSite"));
			language.setNoDataYouWant(p.getProperty("noDataYouWant"));
			language.setStoreName(p.getProperty("storeName"));
			language.setDistrict(p.getProperty("district"));
			language.setChooseProvince(p.getProperty("chooseProvince"));
			language.setChooseCity(p.getProperty("chooseCity"));
			language.setChooseArea(p.getProperty("chooseArea"));
			language.setYetai(p.getProperty("yetai"));
			language.setStartTime(p.getProperty("startTime"));
			language.setStaffNo(p.getProperty("staffNo"));
			language.setSiteStatus(p.getProperty("siteStatus"));
			language.setArea(p.getProperty("area"));
			language.setAddress(p.getProperty("address"));
			language.setStoreType(p.getProperty("storeType"));
			language.setSaveAndAddNext(p.getProperty("saveAndAddNext"));
			language.setUpload(p.getProperty("upload"));
			language.setStoreStatus(p.getProperty("storeStatus"));
			language.setRunning(p.getProperty("running"));
			language.setPause(p.getProperty("pause"));
			language.setClosed(p.getProperty("closed"));
			language.setEdit(p.getProperty("edit"));
			language.setDetail(p.getProperty("detail"));
			language.setAddressEmpty(p.getProperty("addressEmpty"));
			language.setAreaErr(p.getProperty("areaErr"));
			language.setStoreNameEmpty(p.getProperty("storeNameEmpty"));
			language.setHistoryIndexWeekly(p.getProperty("historyIndexWeekly"));
			language.setIndexExplain(p.getProperty("indexExplain"));
			language.setLastTwoWeek(p.getProperty("lastTwoWeek"));
			language.setIndexWeeklyCompare(p.getProperty("indexWeeklyCompare"));
			language.setRealName(p.getProperty("realName"));
			language.setStatus(p.getProperty("status"));
			language.setAddUser(p.getProperty("addUser"));
			language.setSearchUser(p.getProperty("searchUser"));
			language.setSitePriv(p.getProperty("sitePriv"));
			language.setLockUser(p.getProperty("lockUser"));
			language.setUnlockUser(p.getProperty("unlockUser"));
			language.setOpenUser(p.getProperty("openUser"));
			language.setDelUser(p.getProperty("delUser"));
			language.setEditUser(p.getProperty("editUser"));
			language.setUserNameAllNumber(p.getProperty("userNameAllNumber"));
			language.setInputPwd(p.getProperty("inputPwd"));
			language.setMemoLong(p.getProperty("memoLong"));
			language.setChooseSitePriv(p.getProperty("chooseSitePriv"));
			language.setChooseDataPriv(p.getProperty("chooseDataPriv"));
			language.setDeleted(p.getProperty("deleted"));
			language.setReportPriv(p.getProperty("reportPriv"));
			language.setDefaultPwd(p.getProperty("defaultPwd"));
			language.setUserPriv(p.getProperty("userPriv"));
			language.setPcEnable(p.getProperty("pcEnable"));
			language.setMobileEnable(p.getProperty("mobileEnable"));
			language.setSendmsg(p.getProperty("sendmsg"));
			language.setUserInfo(p.getProperty("userInfo"));
			language.setInputYourName(p.getProperty("inputYourName"));
			language.setPosManager(p.getProperty("posManager"));
			language.setSiteType(p.getProperty("siteType"));
			language.setRootNode(p.getProperty("rootNode"));
			language.setGroup(p.getProperty("group"));
			language.setRegion(p.getProperty("region"));
			language.setStore(p.getProperty("store"));
			language.setStoreDis(p.getProperty("storeDis"));
			language.setPassageway(p.getProperty("passageway"));
			language.setFloor(p.getProperty("floor"));
			language.setDomain(p.getProperty("domain"));
			language.setPosImport(p.getProperty("posImport"));
			language.setSquare(p.getProperty("square"));
			language.setSiteManager(p.getProperty("siteManager"));
			language.setChina(p.getProperty("china"));
			language.setSiteUpload(p.getProperty("siteUpload"));
			language.setMorning(p.getProperty("morning"));
			language.setAfternoon(p.getProperty("afternoon"));
			language.setBasicInfoChange(p.getProperty("basicInfoChange"));
			language.setPersonalInfo(p.getProperty("personalInfo"));
			language.setTime(p.getProperty("time"));
			language.setRecordNum(p.getProperty("recordNum"));
			language.setSortByNum(p.getProperty("sortByNum"));
			language.setSortBySale(p.getProperty("sortBySale"));
			language.setShowOfData(p.getProperty("showOfData"));
			language.setCompWeatherAnaly(p.getProperty("compWeatherAnaly"));
			language.setNumOfCustom(p.getProperty("numOfCustom"));
			language.setAveTimeWand(p.getProperty("aveTimeWand"));
			language.setHisWeatherAnaly(p.getProperty("hisWeatherAnaly"));
			language.setWeatherWeekComparAnaly(p.getProperty("weatherWeekComparAnaly"));
			language.setHisWeather(p.getProperty("hisWeather"));
			language.setNewCusNum(p.getProperty("newCusNum"));
			language.setOldCusNu(p.getProperty("oldCusNu"));
			language.setNewCusPer(p.getProperty("newCusPer"));
			language.setMembership(p.getProperty("membership"));
			language.setMembershipPer(p.getProperty("membershipPer"));
			language.setThisWeek(p.getProperty("thisWeek"));
			language.setLastWeek(p.getProperty("lastWeek"));
			language.setHistIndexRank(p.getProperty("histIndexRank"));
			language.setOldCusPer(p.getProperty("oldCusPer"));
			language.setLossAmt(p.getProperty("lossAmt"));
			language.setLossAvg(p.getProperty("lossAvg"));
			language.setBackAmt(p.getProperty("backAmt"));
			language.setBackAvg(p.getProperty("backAvg"));
			language.setCompare(p.getProperty("compare"));
			language.setSite(p.getProperty("site"));
			language.setIndex(p.getProperty("index"));
			language.setRanking(p.getProperty("ranking"));
			language.setAll(p.getProperty("all"));
			language.setChoice(p.getProperty("choice"));
			language.setHistory(p.getProperty("history"));
			language.setAnalyse(p.getProperty("analyse"));
			language.setCompareByTime(p.getProperty("compareByTime"));
			language.setCancleCompare(p.getProperty("cancleCompare"));
			language.setSquareAll(p.getProperty("squareAll"));
			language.setKeyWord(p.getProperty("keyWord"));
			language.setPosDate(p.getProperty("posDate"));
			language.setManualInput(p.getProperty("manualInput"));
			language.setShopLocation(p.getProperty("shopLocation"));
			language.setViewDetail(p.getProperty("viewDetail"));
			language.setPosBack(p.getProperty("posBack"));
			language.setPosDetail(p.getProperty("posDetail"));
			language.setDataDesc(p.getProperty("dataDesc"));
			language.setBianhao(p.getProperty("bianhao"));
			language.setMingcheng(p.getProperty("mingcheng"));
			language.setRi(p.getProperty("ri"));
			language.setGuanjianzitip(p.getProperty("guanjianzitip"));
			language.setDataOverview(p.getProperty("dataOverview"));
			language.setHideSite(p.getProperty("hideSite"));
		}
		return language;
	}
	/**
	 * 获取资源文件
	 * @param lang
	 * @throws Exception
	 */
	private static void getInfoMap(String lang) throws Exception {
		p = new Properties();
		String temp = MessageManager.class.getResource("/").getPath()
				.replaceAll("%20", " ");
		FileInputStream fr = new FileInputStream(temp+ lang+".lang"); 
		InputStreamReader isr = new InputStreamReader(fr,"ISO-8859-1"); 
		//InputStream in = new BufferedInputStream(fr);
		BufferedReader bf = new BufferedReader(isr);  
		p.load(bf);
	}
}
